<?php

namespace app\controller\api;

use app\BaseController;

use app\logic\GroupLogic;

class Group extends BaseController
{
    public function add()
    {
        $data = $this->getData(['name'], ['name|群昵称' => 'require|chsDash|max:10']);
        $user = $this->request->__get('user');
        if ($group_id = GroupLogic::add($data['name'], $user['uid']))
            \Api::success(['group_id' => $group_id]);
        \Api::error('创建群失败');
    }

    public function join()
    {
        $data = $this->getData(['group_id'], ['group_id|群' => 'require|number']);
        $user = $this->request->__get('user');
        if (GroupLogic::join($data['group_id'], $user['uid']))
            \Api::success();
        \Api::error();
    }

    public function del()
    {

    }

}